package com.sys.user.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.sys.api.Controller.OrderUserController;
import com.sys.api.Service.OrderUserService;
import com.sys.common.ZuelResult;
import com.sys.vo.CreateOrderVo;
import com.sys.vo.OrderAll;
import com.sys.vo.OrderResponse;
import com.sys.vo.OrdersList;

import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/orderfunction")
public class OrderUserControllerImpl implements OrderUserController {

	@Autowired
	private OrderUserService service;
	
	@Override
	@PostMapping("/createOrder")
	@ApiOperation(value="用户创建工单接口" ,notes="传一个工单信息即可，不用传id，但是要传uid")
	public ZuelResult createOrder(@RequestBody CreateOrderVo order) {
		// TODO Auto-generated method stub
		return service.createOrder(order);
	}

	@Override
	@PostMapping("/response")
	@ApiOperation(value="用户回复工单" ,notes="传一个工单信息,传工单编号和内容,不要传客服id")
	public ZuelResult responseOrder(@RequestBody OrderResponse res) {
		// TODO Auto-generated method stub
		return service.responseOrder(res);
	}

	@GetMapping("/closeorder")
	@Override
	@ApiOperation(value="用户关闭工单" ,notes="传工单id")
	public ZuelResult closeOrder(@RequestParam Integer oid) {
		// TODO Auto-generated method stub
		return service.closeOrder(oid);
	}

	@GetMapping("/getorder")
	@ApiOperation(value="用户具体工单的回复内容,1表示用户，2表示客服" ,notes="传工单id")
	@Override
	public OrderAll getOrders(@RequestParam int oid) {
		// TODO Auto-generated method stub
		return service.getOrders(oid);
	}

	@GetMapping("/getorderlist")
	@Override
	@ApiOperation(value="用户的所有工单列表" ,notes="传用户id")
	public OrdersList getOrderList(@RequestParam String uname) {
		// TODO Auto-generated method stub
		return service.getOrderList(uname);
	}

}
